//
//  HNSH_LevelCell.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/5/29.
//

#import "HNSH_LevelCell.h"

@interface HNSH_LevelCell ()

/** */
@property (nonatomic, strong)UIImageView * imgView;
/** */
@property (nonatomic, strong)UILabel * nameLabel;
/** */
@property (nonatomic, strong)UILabel * desLabel;
/** */
@property (nonatomic, strong)UILabel * priceLabel;
/** */
@property (nonatomic, strong)UIImageView * curImgView;

@end

@implementation HNSH_LevelCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self configUI];
    }
    return self;
}

- (void)configUI {
    [self addAllViews];
    [self addAllLayout];
}

//MARK: Myself Methods
- (void)addAllViews{
    [self.contentView addSubview:self.imgView];
    [self.imgView addSubview:self.nameLabel];
    [self.imgView addSubview:self.desLabel];
    [self.imgView addSubview:self.priceLabel];
    [self.contentView addSubview:self.curImgView];
}

- (void)addAllLayout{
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(23);
        make.top.mas_equalTo(15);
        make.height.mas_equalTo(28);
    }];
    [self.desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.nameLabel);
        make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(1);
        make.height.mas_equalTo(17);
    }];
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.centerY.mas_equalTo(0);
    }];
    [self.curImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.width.mas_equalTo(68);
        make.height.mas_equalTo(20);
    }];
}

//MARK: Setter Methods
- (void)setModel:(HNSH_LevelModel *)model{
    _model = model;
    
    self.nameLabel.text = model.title;
    self.desLabel.text = model.upgrade_rule_desc;
    self.priceLabel.text = model.poundage_ratio_desc;
    self.curImgView.hidden = model.status == 1 ? NO : YES;
}

//MARK: Getter Methods
- (UIImageView *)imgView{
    if (!_imgView) {
        _imgView = [UIImageView new];
        _imgView.image = [UIImage imageNamed:@"jydj_bg"];
    }
    return _imgView;
}

- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [UILabel new];
        _nameLabel.font = [UIFont boldSystemFontOfSize:20];
        _nameLabel.textColor = [UIColor colorWithHexString:@"#9B5607"];
        _nameLabel.text = @"L0";
    }
    return _nameLabel;
}

- (UILabel *)desLabel{
    if (!_desLabel) {
        _desLabel = [UILabel new];
        _desLabel.font = [UIFont systemFontOfSize:12];
        _desLabel.textColor = [UIColor colorWithHexString:@"#B3742B"];
        _desLabel.text = @"注册未认证通过的用户";
    }
    return _desLabel;
}

- (UILabel *)priceLabel{
    if (!_priceLabel) {
        _priceLabel = [UILabel new];
        _priceLabel.font = [UIFont boldSystemFontOfSize:14];
        _priceLabel.textColor = [UIColor colorWithHexString:@"#A42E2E"];
        _priceLabel.textAlignment = NSTextAlignmentRight;
        _priceLabel.text = @"手续费30%";
    }
    return _priceLabel;
}

- (UIImageView *)curImgView{
    if (!_curImgView) {
        _curImgView = [UIImageView new];
        _curImgView.image = [UIImage imageNamed:@"jydj_select_icon"];
        _curImgView.hidden = YES;
    }
    return _curImgView;
}

@end
